import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xindong/common/xindong_define.dart';
import 'package:xindong/routes/call/controller/xindong_call_rtc_volumes_ctr.dart';
import 'package:xindong/routes/call/controller/xindong_water_ripple_provider.dart';
import 'package:xindong/routes/call/model/xindong_call_volume_class.dart';
import 'package:xindong/utils/xindong_image_util.dart';
import 'package:xindong/widgets/xindong_avatar.dart';

// 1v1 语音层
class XinDongCallRTCAudioView extends StatelessWidget {
  const XinDongCallRTCAudioView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.topCenter,
      padding: EdgeInsets.only(top: 80 + statusBarHeight),
      child: Stack(
        alignment: Alignment.topCenter,
        children: [
          // SizedBox(
          //   width: 375,
          //   height: 375,
          //   child: ImageHelper.networkImageUrl(
          //     "http://qianhe.cn-gd.ufileos.com/images/call-audio-heart.gif",
          //     fit: BoxFit.fitWidth,
          //     placeholder: const SizedBox(),
          //   ),
          // ),
          Align(
            heightFactor: 2.8,
            child: Stack(
              alignment: Alignment.center,
              children: [
                GetBuilder<XinDongCallRTCVolumesController>(builder: (controller) {
                  return Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      userView(controller.targetClass),
                      const SizedBox(width: 66),
                      userView(controller.mineClass),
                    ],
                  );
                }),
                SizedBox(
                  width: 54,
                  height: 44,
                  child: ImageUtil.networkImageUrl(
                    "http://qianhe.cn-gd.ufileos.com/images/call-heart.png",
                    fit: BoxFit.fitWidth,
                    placeholder: const SizedBox(),
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }

  Widget userView(XinDongCallVolumeClass model) {
    double sizeWidth = 72.0;
    return Stack(
      alignment: Alignment.center,
      children: [
        // 声波
        XinDongWaterRippleProvider.createProvider(
          volume: model.volume ?? 0,
          minWidth: sizeWidth,
        ),

        XinDongAvatarBorder(model.user, avatarSize: sizeWidth, borderWidth: 2.0),
      ],
    );
  }
}
